#include <REGX52.H>
#include "xingshikongzhi.h"
#include "delay.h"
#include "xunji.h"
#include "jiaodu.h"

sbit s1 = P2^3;
sbit s2 = P2^2;
sbit s3 = P2^1;
sbit s4 = P2^0;

//#define s1==0&&s2==1&&s3==1&&s4==0 1
static char area;


void xunji()
{
	
	if(s1==0&&s2==1&&s3==1&&s4==0)
	{car_doing_1(1,100,100);
		area=1;
	}
	
	else if(s1==0&&s2==0&&s3==1&&s4==0)
	{
		jiadu_right(1);
		area=2;
	}	
	
	else if(s1==0&&s2==1&&s3==0&&s4==0)
	{
		jiadu_lift(1);
		area=3;
		
	}
	
	else if(s1==0&&s2==0&&s3==0&&s4==1)
	{
		jiadu_right(3);
		area=4;

	}
	
	else if(s1==1&&s2==0&&s3==0&&s4==0)
	{
		jiadu_lift(3);
		area=5;
			
	}
	else if(s1==0&&s2==0&&s3==0&&s4==0)
	{
		if(area==3)
		{
			jiadu_lift(2);
		}
		else if(area==2)
		{
			jiadu_right(2);
		}
		else if(area==4)
		{
			jiadu_right(4);
		}
		else if(area==5)
		{
			jiadu_lift(4);
		}
	}
}



	
char run_mode = 1;
void func(){
    static int i = 0;
    i++;
    if (i<=10) {do_someting();}
    else {run_mode = 0;}
}

void T0(){
    static int i = 0;
    i++;
    if (run_mode == 1 && i>=1000){
        i=0;
        func();
    }
}


